// 用户相关请求模块
import request from '@/utils/request'

// 用户认证（登录注册）
export const login = (data) => {
  return request({
    method: 'POST',
    url: '/v1_0/authorizations',
    data,
  })
}
// 发送短信
export const sendSms = (mobile) => {
  return request({
    method: 'GET',
    url: `/v1_0/sms/codes/${mobile}`,
  })
}

// 获取个人信息
export const getUserInfo = () => {
  return request({
    method: 'GET',
    // 这个接口加/app能用，不然用不了
    url: '/v1_0/user',
  })
}

// 获取用户个人资料
export const getUserProfile = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user/profile',
  })
}
// 更新用户个人资料
export const updateUserProfile = (data) => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/profile',
    data
  })
}
// 更新用户头像
export const updateUserPhoto = (data) => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/photo',
    data
  })
}
// 关注用户
export const addFollow = (target) => {
  return request({
    method: "POST",
    url: '/v1_0/user/followings',
    data: {
      target
    }
  })
}
// 取消关注用户
export const deleteFollow = (target) => {
  return request({
    method: "DELETE",
    url: `/v1_0/user/followings/${target}`,
    data: {
      target
    }
  })
}